From: Sebastian Keller Date: Fri, 4 Sep 2026 11:52:27 +0000 (+0200) Subject: brightnessManager: Make BrightnessScale destroyable X-Git-Tag: archive/raspbian/50.5-1+rpi1^2~6^2^2~24 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e5f254bdfa6f7bd6ec9c049e67d9c30a26e97b34;p=gnome-shell.git brightnessManager: Make BrightnessScale destroyable `BrightnessScale` is being connected to with `connectObject()` from a non-destroyable object (`BrightnessManager`) and it itself also connects to non-destroyable objects using this method. Since none of these objects are triggering the signal cleanup in the signal tracker, this was causing all of the involved objects, including the signal tracker to get leaked. This was happening for example on anything that triggers the `monitors-changed` signal, such as switching VTs. To fix this make `BrightnessScale` destroyable and destroy them when necessary. Part-of: (cherry picked from commit 457f781e16fa5a309292fb1b920e64f29362afca) --- diff --git a/js/misc/brightnessManager.js b/js/misc/brightnessManager.js index feb38ecab..15bbc49c6 100644 --- a/js/misc/brightnessManager.js +++ b/js/misc/brightnessManager.js @@ -4,6 +4,7 @@ import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; import * as Main from '../ui/main.js'; +import * as SignalTracker from '../misc/signalTracker.js'; const SCALE_VALUE_N_STEPS = 20; const SCALE_VALUE_CHANGE_EPSILON = 0.001; @@ -141,6 +142,7 @@ export const BrightnessManager = GObject.registerClass({ .some(m => m.get_backlight() && m.is_active()); }); + this._monitorScales.values().forEach(scale => scale.destroy()); this._monitorScales.clear(); for (const monitor of monitors) { @@ -283,6 +285,9 @@ export const BrightnessScale = GObject.registerClass({ GObject.ParamFlags.READWRITE, 0, 1.0, 1.0), }, + Signals: { + 'destroy': {}, + }, }, class BrightnessScale extends GObject.Object { constructor(name, value = 1.0, nSteps = SCALE_VALUE_N_STEPS) { super(); @@ -327,7 +332,12 @@ export const BrightnessScale = GObject.registerClass({ this._value = Math.clamp(value, 0.0, 1.0); this.notify('value'); } + + destroy() { + this.emit('destroy'); + } }); +SignalTracker.registerDestroyableType(BrightnessScale); const MonitorBrightnessScale = GObject.registerClass({ Signals: {